package cn.cvs.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigManager {
    private static Properties properties;
    private static ConfigManager configManager=null;
    /**
     * 杜绝外界创建该类对象，私有构造方法
     */
    private ConfigManager(){
        String configFile="database.properties";
        properties=new Properties();
        InputStream is=ConfigManager.class.getClassLoader().getResourceAsStream(configFile);
        try {
            properties.load(is);
            is.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    /**
     * 对外提供的获取ConfigManager实例的方法
     */
    public static ConfigManager getInstance(){
        if (configManager==null){
            configManager=new ConfigManager();
        }
        return configManager;
    }
}
